package com.terrace.core.utils;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

/**
 * 自定义数组工具
 * @author jiangyg
 *
 */
public class CustomArrayUtils {
	
	/**
	 * 抽取原来数组有的但是新的数组没有的字符集合
	 * @param originalArrays			原数组
	 * @param newArrays					新数组
	 * @return
	 */
	public static List<String> extractOriginalExcludeNewForArray(List<String> originalArrays, List<String> newArrays) {
		List<String> extract = new ArrayList<String>();
		for (String original : originalArrays) {
			if (StringUtils.isNotBlank(original) && !newArrays.contains(original)) {
				extract.add(original);
			}
		}
		return extract;
	}
	
	/**
	 * 抽取新数组有但是原数组没有的字符集合
	 * @param originalArrays
	 * @param newArrays
	 * @return
	 */
	public static List<String> extractNewExcludeOriginalForArray(List<String> originalArrays, List<String> newArrays) {
		List<String> extract = new ArrayList<String>();
		for (String newArray : newArrays) {
			if (StringUtils.isNotBlank(newArray) && !originalArrays.contains(newArray)) {
				extract.add(newArray);
			}
		}
		return extract;
	}

}
